﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="sooritakanne_kandesisu_v4", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(SooritakanneKandesisuV4))]
    public class SooritakanneKandesisuV4Serializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected ISooritakanneKandesisuV4 clazz;
        
        public SooritakanneKandesisuV4Serializer(ISooritakanneKandesisuV4 clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.UusArinimi!=null) {
                Writer.WriteStartElement("uus_arinimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.UusArinimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.OiguslikVorm!=null) {
                Writer.WriteStartElement("oiguslik_vorm");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OiguslikVorm))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.OiguslikuVormiAlaliik!=null) {
                Writer.WriteStartElement("oigusliku_vormi_alaliik");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OiguslikuVormiAlaliik))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Asukoht!=null) {
                Writer.WriteStartElement("asukoht");
                global::Xtee.Core.SerializationMetadata metaAsukoht = this.GetMetaData(clazz.Asukoht);
                Writer.WriteTypeAttribute(metaAsukoht.TypeQualifiedName.Namespace, metaAsukoht.TypeQualifiedName.Name);
                metaAsukoht.NewSerializer(clazz.Asukoht).WriteXml(Writer);
                Writer.WriteEndElement();
            }
            if (clazz.EvSeisund!=null) {
                Writer.WriteStartElement("ev_seisund");
                global::Xtee.Core.SerializationMetadata metaEvSeisund = this.GetMetaData(clazz.EvSeisund);
                Writer.WriteTypeAttribute(metaEvSeisund.TypeQualifiedName.Namespace, metaEvSeisund.TypeQualifiedName.Name);
                metaEvSeisund.NewSerializer(clazz.EvSeisund).WriteXml(Writer);
                Writer.WriteEndElement();
            }
            if (clazz.Pohitegevusala!=null) {
                Writer.WriteStartElement("pohitegevusala");
                global::Xtee.Core.SerializationMetadata metaPohitegevusala = this.GetMetaData(clazz.Pohitegevusala);
                Writer.WriteTypeAttribute(metaPohitegevusala.TypeQualifiedName.Namespace, metaPohitegevusala.TypeQualifiedName.Name);
                metaPohitegevusala.NewSerializer(clazz.Pohitegevusala).WriteXml(Writer);
                Writer.WriteEndElement();
            }
            if (clazz.Lisategevusala!=null) {
                Writer.WriteStartElement("lisategevusala");
                global::Xtee.Core.SerializationMetadata metaLisategevusala = this.GetMetaData(clazz.Lisategevusala);
                Writer.WriteTypeAttribute(metaLisategevusala.TypeQualifiedName.Namespace, metaLisategevusala.TypeQualifiedName.Name);
                metaLisategevusala.NewSerializer(clazz.Lisategevusala).WriteXml(Writer);
                Writer.WriteEndElement();
            }
            for (int x = 0; ((clazz.Eesmargid != null) 
                        && (x < clazz.Eesmargid.Count)); x = (x + 1)) {
                if (clazz.Eesmargid[x]!=null) {
                    Writer.WriteStartElement("eesmargid");
                    global::Xtee.Core.SerializationMetadata metaEesmargid = this.GetMetaData(clazz.Eesmargid[x]);
                    Writer.WriteTypeAttribute(metaEesmargid.TypeQualifiedName.Namespace, metaEesmargid.TypeQualifiedName.Name);
                    metaEesmargid.NewSerializer(clazz.Eesmargid[x]).WriteXml(Writer);
                    Writer.WriteEndElement();
                }
            }
            if (clazz.Majandusaasta!=null) {
                Writer.WriteStartElement("majandusaasta");
                global::Xtee.Core.SerializationMetadata metaMajandusaasta = this.GetMetaData(clazz.Majandusaasta);
                Writer.WriteTypeAttribute(metaMajandusaasta.TypeQualifiedName.Namespace, metaMajandusaasta.TypeQualifiedName.Name);
                metaMajandusaasta.NewSerializer(clazz.Majandusaasta).WriteXml(Writer);
                Writer.WriteEndElement();
            }
            if (clazz.Kapital!=null) {
                Writer.WriteStartElement("kapital");
                global::Xtee.Core.SerializationMetadata metaKapital = this.GetMetaData(clazz.Kapital);
                Writer.WriteTypeAttribute(metaKapital.TypeQualifiedName.Namespace, metaKapital.TypeQualifiedName.Name);
                metaKapital.NewSerializer(clazz.Kapital).WriteXml(Writer);
                Writer.WriteEndElement();
            }
            if (clazz.KapitaliTingimuslikSuurendamine!=null) {
                Writer.WriteStartElement("kapitali_tingimuslik_suurendamine");
                global::Xtee.Core.SerializationMetadata metaKapitaliTingimuslikSuurendamine = this.GetMetaData(clazz.KapitaliTingimuslikSuurendamine);
                Writer.WriteTypeAttribute(metaKapitaliTingimuslikSuurendamine.TypeQualifiedName.Namespace, metaKapitaliTingimuslikSuurendamine.TypeQualifiedName.Name);
                metaKapitaliTingimuslikSuurendamine.NewSerializer(clazz.KapitaliTingimuslikSuurendamine).WriteXml(Writer);
                Writer.WriteEndElement();
            }
            if (clazz.NimivaartusetaAktsiateArv!=null) {
                Writer.WriteStartElement("nimivaartuseta_aktsiate_arv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.NimivaartusetaAktsiateArv))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AsutatudSissemaksetTegemata!=null) {
                Writer.WriteStartElement("asutatud_sissemakset_tegemata");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "boolean");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdBoolean(((bool)(clazz.AsutatudSissemaksetTegemata))).ToString());
                Writer.WriteEndElement();
            }
            for (int x = 0; ((clazz.OmandiOsad != null) 
                        && (x < clazz.OmandiOsad.Count)); x = (x + 1)) {
                if (clazz.OmandiOsad[x]!=null) {
                    Writer.WriteStartElement("omandi_osad");
                    global::Xtee.Core.SerializationMetadata metaOmandiOsad = this.GetMetaData(clazz.OmandiOsad[x]);
                    Writer.WriteTypeAttribute(metaOmandiOsad.TypeQualifiedName.Namespace, metaOmandiOsad.TypeQualifiedName.Name);
                    metaOmandiOsad.NewSerializer(clazz.OmandiOsad[x]).WriteXml(Writer);
                    Writer.WriteEndElement();
                }
            }
            for (int x = 0; ((clazz.Isikud != null) 
                        && (x < clazz.Isikud.Count)); x = (x + 1)) {
                if (clazz.Isikud[x]!=null) {
                    Writer.WriteStartElement("isikud");
                    global::Xtee.Core.SerializationMetadata metaIsikud = this.GetMetaData(clazz.Isikud[x]);
                    Writer.WriteTypeAttribute(metaIsikud.TypeQualifiedName.Namespace, metaIsikud.TypeQualifiedName.Name);
                    metaIsikud.NewSerializer(clazz.Isikud[x]).WriteXml(Writer);
                    Writer.WriteEndElement();
                }
            }
            for (int x = 0; ((clazz.Esindusoigused != null) 
                        && (x < clazz.Esindusoigused.Count)); x = (x + 1)) {
                if (clazz.Esindusoigused[x]!=null) {
                    Writer.WriteStartElement("esindusoigused");
                    global::Xtee.Core.SerializationMetadata metaEsindusoigused = this.GetMetaData(clazz.Esindusoigused[x]);
                    Writer.WriteTypeAttribute(metaEsindusoigused.TypeQualifiedName.Namespace, metaEsindusoigused.TypeQualifiedName.Name);
                    metaEsindusoigused.NewSerializer(clazz.Esindusoigused[x]).WriteXml(Writer);
                    Writer.WriteEndElement();
                }
            }
            if (clazz.Pohikiri!=null) {
                Writer.WriteStartElement("pohikiri");
                global::Xtee.Core.SerializationMetadata metaPohikiri = this.GetMetaData(clazz.Pohikiri);
                Writer.WriteTypeAttribute(metaPohikiri.TypeQualifiedName.Namespace, metaPohikiri.TypeQualifiedName.Name);
                metaPohikiri.NewSerializer(clazz.Pohikiri).WriteXml(Writer);
                Writer.WriteEndElement();
            }
            for (int x = 0; ((clazz.Sidevahendid != null) 
                        && (x < clazz.Sidevahendid.Count)); x = (x + 1)) {
                if (clazz.Sidevahendid[x]!=null) {
                    Writer.WriteStartElement("sidevahendid");
                    global::Xtee.Core.SerializationMetadata metaSidevahendid = this.GetMetaData(clazz.Sidevahendid[x]);
                    Writer.WriteTypeAttribute(metaSidevahendid.TypeQualifiedName.Namespace, metaSidevahendid.TypeQualifiedName.Name);
                    metaSidevahendid.NewSerializer(clazz.Sidevahendid[x]).WriteXml(Writer);
                    Writer.WriteEndElement();
                }
            }
            for (int x = 0; ((clazz.Markused != null) 
                        && (x < clazz.Markused.Count)); x = (x + 1)) {
                if (clazz.Markused[x]!=null) {
                    Writer.WriteStartElement("markused");
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Markused[x]))).ToString());
                    Writer.WriteEndElement();
                }
            }
            if (clazz.TegutsemiseAlgus!=null) {
                Writer.WriteStartElement("tegutsemise_algus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.TegutsemiseAlgus))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.TegutsemiseTahtaeg!=null) {
                Writer.WriteStartElement("tegutsemise_tahtaeg");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.TegutsemiseTahtaeg))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AsutamiseAeg!=null) {
                Writer.WriteStartElement("asutamise_aeg");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AsutamiseAeg))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.ViideEelkaijale!=null) {
                Writer.WriteStartElement("viide_eelkaijale");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.ViideEelkaijale))).ToString());
                Writer.WriteEndElement();
            }
            for (int x = 0; ((clazz.Kinnisasjad != null) 
                        && (x < clazz.Kinnisasjad.Count)); x = (x + 1)) {
                if (clazz.Kinnisasjad[x]!=null) {
                    Writer.WriteStartElement("kinnisasjad");
                    global::Xtee.Core.SerializationMetadata metaKinnisasjad = this.GetMetaData(clazz.Kinnisasjad[x]);
                    Writer.WriteTypeAttribute(metaKinnisasjad.TypeQualifiedName.Namespace, metaKinnisasjad.TypeQualifiedName.Name);
                    metaKinnisasjad.NewSerializer(clazz.Kinnisasjad[x]).WriteXml(Writer);
                    Writer.WriteEndElement();
                }
            }
            if (clazz.ValismaaEmaettevote!=null) {
                Writer.WriteStartElement("valismaa_emaettevote");
                global::Xtee.Core.SerializationMetadata metaValismaaEmaettevote = this.GetMetaData(clazz.ValismaaEmaettevote);
                Writer.WriteTypeAttribute(metaValismaaEmaettevote.TypeQualifiedName.Namespace, metaValismaaEmaettevote.TypeQualifiedName.Name);
                metaValismaaEmaettevote.NewSerializer(clazz.ValismaaEmaettevote).WriteXml(Writer);
                Writer.WriteEndElement();
            }
            for (int x = 0; ((clazz.FieSeisundid != null) 
                        && (x < clazz.FieSeisundid.Count)); x = (x + 1)) {
                if (clazz.FieSeisundid[x]!=null) {
                    Writer.WriteStartElement("fie_seisundid");
                    global::Xtee.Core.SerializationMetadata metaFieSeisundid = this.GetMetaData(clazz.FieSeisundid[x]);
                    Writer.WriteTypeAttribute(metaFieSeisundid.TypeQualifiedName.Namespace, metaFieSeisundid.TypeQualifiedName.Name);
                    metaFieSeisundid.NewSerializer(clazz.FieSeisundid[x]).WriteXml(Writer);
                    Writer.WriteEndElement();
                }
            }
            if (clazz.MaksRegKpv!=null) {
                Writer.WriteStartElement("maks_reg_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.MaksRegKpv))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="uus_arinimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisu_v4>uus_arinimi");
                }
                clazz.UusArinimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("uus_arinimi")).Value;
            }
            if (Reader.LocalName=="oiguslik_vorm") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisu_v4>oiguslik_vorm");
                }
                clazz.OiguslikVorm = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("oiguslik_vorm")).Value;
            }
            if (Reader.LocalName=="oigusliku_vormi_alaliik") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.OiguslikuVormiAlaliik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("oigusliku_vormi_alaliik")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="asukoht") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisu_v4>asukoht");
                }
                global::Xtee.Core.SerializationMetadata metaAsukoht = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IAadressTypeV4>(Reader, "aadressType_v4", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                clazz.Asukoht = metaAsukoht.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IAadressTypeV4>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("asukoht");
                    metaAsukoht.NewSerializer(clazz.Asukoht).ReadXml(Reader);
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="ev_seisund") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisu_v4>ev_seisund");
                }
                global::Xtee.Core.SerializationMetadata metaEvSeisund = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IEvSeisundTypeV4>(Reader, "ev_seisundType_v4", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                clazz.EvSeisund = metaEvSeisund.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IEvSeisundTypeV4>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("ev_seisund");
                    metaEvSeisund.NewSerializer(clazz.EvSeisund).ReadXml(Reader);
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="pohitegevusala") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisu_v4>pohitegevusala");
                }
                global::Xtee.Core.SerializationMetadata metaPohitegevusala = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ITegevusalaTypeV4>(Reader, "tegevusalaType_v4", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                clazz.Pohitegevusala = metaPohitegevusala.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ITegevusalaTypeV4>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("pohitegevusala");
                    metaPohitegevusala.NewSerializer(clazz.Pohitegevusala).ReadXml(Reader);
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="lisategevusala") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisu_v4>lisategevusala");
                }
                global::Xtee.Core.SerializationMetadata metaLisategevusala = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ITegevusalaTypeV4>(Reader, "tegevusalaType_v4", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                clazz.Lisategevusala = metaLisategevusala.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ITegevusalaTypeV4>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("lisategevusala");
                    metaLisategevusala.NewSerializer(clazz.Lisategevusala).ReadXml(Reader);
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="eesmargid") {
                clazz.Eesmargid = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IEesmargidTypeV4>();
                for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                            && (Reader.LocalName == "eesmargid")); ) {
                    if ((Reader.IsElementNil() == false)) {
                        global::Xtee.Core.SerializationMetadata metaEesmargid = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IEesmargidTypeV4>(Reader, "eesmargidType_v4", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IEesmargidTypeV4 item = metaEesmargid.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IEesmargidTypeV4>();
                        clazz.Eesmargid.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("eesmargid");
                            metaEesmargid.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    else {
                        clazz.Eesmargid.Add(null);
                        Reader.Skip();
                    }
                }
            }
            if (Reader.LocalName=="majandusaasta") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisu_v4>majandusaasta");
                }
                global::Xtee.Core.SerializationMetadata metaMajandusaasta = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISooritakanneMajaastaV4>(Reader, "sooritakanne_majaasta_v4", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                clazz.Majandusaasta = metaMajandusaasta.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISooritakanneMajaastaV4>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("majandusaasta");
                    metaMajandusaasta.NewSerializer(clazz.Majandusaasta).ReadXml(Reader);
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="kapital") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisu_v4>kapital");
                }
                global::Xtee.Core.SerializationMetadata metaKapital = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISooritakanneKapitalV4>(Reader, "sooritakanne_kapital_v4", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                clazz.Kapital = metaKapital.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISooritakanneKapitalV4>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("kapital");
                    metaKapital.NewSerializer(clazz.Kapital).ReadXml(Reader);
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="kapitali_tingimuslik_suurendamine") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisu_v4>kapitali_tingimuslik_suurendamine");
                }
                global::Xtee.Core.SerializationMetadata metaKapitaliTingimuslikSuurendamine = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISooritakanneKapitaliTingimuslikSuurendamineV4>(Reader, "sooritakanne_kapitali_tingimuslik_suurendamine_v4", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                clazz.KapitaliTingimuslikSuurendamine = metaKapitaliTingimuslikSuurendamine.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISooritakanneKapitaliTingimuslikSuurendamineV4>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("kapitali_tingimuslik_suurendamine");
                    metaKapitaliTingimuslikSuurendamine.NewSerializer(clazz.KapitaliTingimuslikSuurendamine).ReadXml(Reader);
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="nimivaartuseta_aktsiate_arv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisu_v4>nimivaartuseta_aktsiate_arv");
                }
                clazz.NimivaartusetaAktsiateArv = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("nimivaartuseta_aktsiate_arv")).Value;
            }
            if (Reader.LocalName=="asutatud_sissemakset_tegemata") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.AsutatudSissemaksetTegemata = new global::Xtee.Core.Schema.XsdBoolean(Reader.ReadElementString("asutatud_sissemakset_tegemata")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="omandi_osad") {
                clazz.OmandiOsad = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IOmandiOsadTypeV4>();
                for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                            && (Reader.LocalName == "omandi_osad")); ) {
                    if ((Reader.IsElementNil() == false)) {
                        global::Xtee.Core.SerializationMetadata metaOmandiOsad = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IOmandiOsadTypeV4>(Reader, "omandiOsadType_v4", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IOmandiOsadTypeV4 item = metaOmandiOsad.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IOmandiOsadTypeV4>();
                        clazz.OmandiOsad.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("omandi_osad");
                            metaOmandiOsad.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    else {
                        clazz.OmandiOsad.Add(null);
                        Reader.Skip();
                    }
                }
            }
            if (Reader.LocalName=="isikud") {
                clazz.Isikud = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IIsikTypeV4>();
                for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                            && (Reader.LocalName == "isikud")); ) {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisu_v4>isikud");
                    }
                    global::Xtee.Core.SerializationMetadata metaIsikud = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IIsikTypeV4>(Reader, "isikType_v4", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                    global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IIsikTypeV4 item = metaIsikud.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IIsikTypeV4>();
                    clazz.Isikud.Add(item);
                    if ((Reader.IsEmptyElement == false)) {
                        Reader.ReadStartElement("isikud");
                        metaIsikud.NewSerializer(item).ReadXml(Reader);
                        Reader.ReadEndElement();
                    }
                    else {
                        Reader.Skip();
                    }
                }
            }
            if (Reader.LocalName=="esindusoigused") {
                clazz.Esindusoigused = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IEsindusoigusTypeV4>();
                for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                            && (Reader.LocalName == "esindusoigused")); ) {
                    if ((Reader.IsElementNil() == false)) {
                        global::Xtee.Core.SerializationMetadata metaEsindusoigused = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IEsindusoigusTypeV4>(Reader, "esindusoigusType_v4", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IEsindusoigusTypeV4 item = metaEsindusoigused.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IEsindusoigusTypeV4>();
                        clazz.Esindusoigused.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("esindusoigused");
                            metaEsindusoigused.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    else {
                        clazz.Esindusoigused.Add(null);
                        Reader.Skip();
                    }
                }
            }
            if (Reader.LocalName=="pohikiri") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisu_v4>pohikiri");
                }
                global::Xtee.Core.SerializationMetadata metaPohikiri = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISooritakannePohikiriV4>(Reader, "sooritakanne_pohikiri_v4", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                clazz.Pohikiri = metaPohikiri.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISooritakannePohikiriV4>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("pohikiri");
                    metaPohikiri.NewSerializer(clazz.Pohikiri).ReadXml(Reader);
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="sidevahendid") {
                clazz.Sidevahendid = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISidevahendTypeV4>();
                for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                            && (Reader.LocalName == "sidevahendid")); ) {
                    if ((Reader.IsElementNil() == false)) {
                        global::Xtee.Core.SerializationMetadata metaSidevahendid = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISidevahendTypeV4>(Reader, "sidevahendType_v4", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISidevahendTypeV4 item = metaSidevahendid.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISidevahendTypeV4>();
                        clazz.Sidevahendid.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("sidevahendid");
                            metaSidevahendid.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    else {
                        clazz.Sidevahendid.Add(null);
                        Reader.Skip();
                    }
                }
            }
            if (Reader.LocalName=="markused") {
                clazz.Markused = new System.Collections.Generic.List<System.String>();
                for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                            && (Reader.LocalName == "markused")); ) {
                    if ((Reader.IsElementNil() == false)) {
                        clazz.Markused.Add(new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("markused")).Value);
                    }
                    else {
                        clazz.Markused.Add(null);
                        Reader.Skip();
                    }
                }
            }
            if (Reader.LocalName=="tegutsemise_algus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisu_v4>tegutsemise_algus");
                }
                clazz.TegutsemiseAlgus = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("tegutsemise_algus")).Value;
            }
            if (Reader.LocalName=="tegutsemise_tahtaeg") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisu_v4>tegutsemise_tahtaeg");
                }
                clazz.TegutsemiseTahtaeg = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("tegutsemise_tahtaeg")).Value;
            }
            if (Reader.LocalName=="asutamise_aeg") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisu_v4>asutamise_aeg");
                }
                clazz.AsutamiseAeg = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("asutamise_aeg")).Value;
            }
            if (Reader.LocalName=="viide_eelkaijale") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisu_v4>viide_eelkaijale");
                }
                clazz.ViideEelkaijale = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("viide_eelkaijale")).Value;
            }
            if (Reader.LocalName=="kinnisasjad") {
                clazz.Kinnisasjad = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IKinnisasiTypeV4>();
                for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                            && (Reader.LocalName == "kinnisasjad")); ) {
                    if ((Reader.IsElementNil() == false)) {
                        global::Xtee.Core.SerializationMetadata metaKinnisasjad = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IKinnisasiTypeV4>(Reader, "kinnisasiType_v4", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IKinnisasiTypeV4 item = metaKinnisasjad.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IKinnisasiTypeV4>();
                        clazz.Kinnisasjad.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("kinnisasjad");
                            metaKinnisasjad.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    else {
                        clazz.Kinnisasjad.Add(null);
                        Reader.Skip();
                    }
                }
            }
            if (Reader.LocalName=="valismaa_emaettevote") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisu_v4>valismaa_emaettevote");
                }
                global::Xtee.Core.SerializationMetadata metaValismaaEmaettevote = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IValismaaEmaettevoteTypeV4>(Reader, "valismaa_emaettevoteType_v4", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                clazz.ValismaaEmaettevote = metaValismaaEmaettevote.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IValismaaEmaettevoteTypeV4>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("valismaa_emaettevote");
                    metaValismaaEmaettevote.NewSerializer(clazz.ValismaaEmaettevote).ReadXml(Reader);
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="fie_seisundid") {
                clazz.FieSeisundid = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IFieSeisundTypeV4>();
                for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                            && (Reader.LocalName == "fie_seisundid")); ) {
                    if ((Reader.IsElementNil() == false)) {
                        global::Xtee.Core.SerializationMetadata metaFieSeisundid = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IFieSeisundTypeV4>(Reader, "fie_seisundType_v4", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IFieSeisundTypeV4 item = metaFieSeisundid.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IFieSeisundTypeV4>();
                        clazz.FieSeisundid.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("fie_seisundid");
                            metaFieSeisundid.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    else {
                        clazz.FieSeisundid.Add(null);
                        Reader.Skip();
                    }
                }
            }
            if (Reader.LocalName=="maks_reg_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisu_v4>maks_reg_kpv");
                }
                clazz.MaksRegKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("maks_reg_kpv")).Value;
            }
        }
    }
}
